<?php 
defined('IN_TS') or die('Access Denied.'); 

function newevent(){
	global $db;
	//最新活动
	if( $GLOBALS['TS_USER']!=''){
		$mylink = '&link='.$GLOBALS['TS_USER']['userid'];
	}
	$arrEvents = aac('event')->findAll('event',
		'isaudit=0 and endtime>'.time()
	,'addtime desc','eventid,userid,typeid,title,count_userdo,count_userwish,addtime',10);

	if (count($arrEvents) > 0) {
		$userids = array_column($arrEvents, "userid");
		$users = aac('user')->getUsers($userids);

		$eventTypes = aac('event')->getEventTypes();
	}
	
	foreach($arrEvents as $key=>$item){

		    $arrEvent[] = $item;
			$arrEvent[$key]['title']=tsTitle($item['title']);
			$arrEvent[$key]['user'] = $users[$item["userid"]];
			$arrEvent[$key]['type'] = $eventTypes[$item['typeid']];

		   }


	include template('newevent','newevent');
	
}

function newevent_css(){

	echo '<link href="'.SITE_URL.'plugins/home/newevent/style.css" rel="stylesheet" type="text/css" />';

}

addAction('home_index_left','newevent');
addAction('pub_header_top','newevent_css');